﻿using Infrastructure.Common.Data;
using Infrastructure.Common.Data.Imp;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TallyBook.Test
{
    [TestClass]
    public class DbTest
    {
        //<summary>
        //执行SQLite命令,删除表
        //</summary>
        [TestMethod]
        public void Test_ExecuteCommond()
        {
            IDbHelper sqliteHelper = new SqliteHelper("../../../../DataBase/tallybook");
            //建立一个SqliteHelper对象，并指出数据库创建的路径

            const string insertCommand = "insert into  user(name,gender) values ('Skyven','男')";
            sqliteHelper.ExecuteCommand(insertCommand);

            const string deleteCommand = "delete from  user where name='Skyven'";
            sqliteHelper.ExecuteCommand(deleteCommand);
        }

        // <summary>
        // 执行SqlServer
        // </summary>
        [TestMethod]
        public void Text_Modification()
        {
            IDbHelper accountService = DbFactory.Instance.CreateDbHelper();
            accountService.ExecuteCommand("updata Account set Id='id'");
        }

        // <summary>
        // 执行查询语句，查询表内所有元素
        //// </summary>
        [TestMethod]
        public void Test_ExecuteQuery()
        {
            IDbHelper sqliteHelper = new SqliteHelper("../../../../DataBase/tallybook");
            //建立一个SqliteHelper对象，并指出数据库创建的路径

            sqliteHelper.ExecuteCommand("select * from User");
        }

        [TestMethod]
        public void Test_Factory()
        {
            IDbHelper dbhelper = DbFactory.Instance.CreateDbHelper();
            dbhelper.ExecuteCommand("select * from User");
        }
    }
}